<template>
  <el-dialog title="添加标签" :visible.sync="tagDialogFormVisible" :before-close="beforeClose">
    <el-form ref="ValidateForm" :rules="{
          name: [
            { required: true, message: '请选择标签名', trigger: 'blur' }, 
          ]
      }" :model="form">
      <el-form-item
        label="标签名"
        prop="name"
        :label-width="formLabelWidth"
      >
        <el-select v-model="form.name" @change="tagChange" placeholder="请选择标签名">
            <el-option label="div" value="div"></el-option>
            <el-option label="img" value="img"></el-option>
            <!-- <el-option label="文字" value="text"></el-option> -->
        </el-select>
      </el-form-item>
      <el-form-item label="文字内容" prop="text">
        <el-input type="textarea" v-model="form.text"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="send(false)">取 消</el-button>
      <el-button type="primary" @click="send(true)">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import {
  Component,
  Emit,
  Inject,
  Model,
  Prop,
  Provide,
  Vue,
  Watch
} from "vue-property-decorator";

@Component
export default class App extends Vue {
  @Prop({ type: Boolean, default: false })
  tagDialogFormVisible;
  form = {
    name: "",
    text:""
  };
  formLabelWidth = "80px";

  tagChange(){
    
    try{

    console.log(this.form.name)
    }catch(e){

    }
  }

  send(value) {
    try{

      this.$emit("changeDialogFormVisible", false, this.form);
      this.$emit("changeDialogFormVisible", true);
    }catch(e){

    }
    if (value) {
      this.$refs.ValidateForm.validate(valid => {
        if (valid) {
        } else {
          return false;
        }
      });
    }
  }
  beforeClose() {
    this.$emit("changeDialogFormVisible", false);
  }
}
</script>

<style lang="less" >
</style>